package com.dy.nygl.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dy.nygl.mapper.EnergyMapper;
import com.dy.nygl.pojo.Energy;
import com.dy.nygl.service.EnergyService;

@Service("energyService")
public class EnergyServiceImpl implements EnergyService {

	@Resource(name = "energyDao")
	private EnergyMapper energyDao;

	@Override
	public void insert(Energy energy) {
		Energy energy2 = new Energy();
		energy2.setName(energy.getName());
		energyDao.insertSelective(energy2);
	}

	@Override
	public List<Energy> selectAll() {
		List<Energy> list = energyDao.selectAll();

		return list;
	}

	@Override
	public void update(Energy energy) {
		Energy energy2 = new Energy();
		energy2.setId(energy.getId());
		energy2.setName(energy.getName());
		energy2.setActual(energy.getActual());
		energy2.setPredict(energy.getPredict());
		energy2.setUnit(energy.getUnit());

		energyDao.updateByPrimaryKeySelective(energy2);

	}

	@Override
	public Energy selectById(Integer id) {
		Energy energy=energyDao.selectByPrimaryKey(id);
		return energy;
	}
}
